JSON decoder/encoder in DXL

Hi !

Does someone want to share with me a DXL implementation of an JSON decoder/encoder ? It seems to be a very basic need for a DXL programmer (I'm not a real one)

It's not a big deal to develop, but I'm a lazy guy ;-) 

regards.


jaracic - Thu May 21 08:48:56 EDT 2015

Re: JSON decoder/encoder in DXL
Mathias Mamsch - Thu May 21 10:22:58 EDT 2015

I think you might have some troubles with that, since DXL is missing the reflective nature of javascript, where you can easily determine an array / object. Imagine you got some JSON and you convert that to ... hmm ... DXL arrays and DXLObjects/Skips (nested)? Then you got no possibility to find out after the conversion how the objects structure is - you do not know the type of the value of a skip list, for example.

That means for a JSON decoder you would need to create special types like JSONArray and JSONObject with special accessors for the properties / elements. Not completely trivial - are you experimenting with the HTTP functions of DXL to use webservices?

Regards, Mathias

Re: JSON decoder/encoder in DXL
jaracic - Thu May 21 16:29:53 EDT 2015

Mathias Mamsch - Thu May 21 10:22:58 EDT 2015

I think you might have some troubles with that, since DXL is missing the reflective nature of javascript, where you can easily determine an array / object. Imagine you got some JSON and you convert that to ... hmm ... DXL arrays and DXLObjects/Skips (nested)? Then you got no possibility to find out after the conversion how the objects structure is - you do not know the type of the value of a skip list, for example.

That means for a JSON decoder you would need to create special types like JSONArray and JSONObject with special accessors for the properties / elements. Not completely trivial - are you experimenting with the HTTP functions of DXL to use webservices?

Regards, Mathias

Hi,

I know that without reflexive mechanism in the language I can implement only something "minimalistic". I actually imagined to convert json buffer in  Dxl arrays, Skips and DxlObjects. I imagine to put taht in a top level DxlObject that could contains information about the nature of the content.

Since I don't know how to create its own type , and associated accessors in DXL (any documentation about that issue?), I didn't measure that work.

 

And yes, I have to create a seamless integration demonstrator (as I said I'm not a real programmer) )with a testLink server for a customer.

 

Regards.

Joseph

Re: JSON decoder/encoder in DXL
Mathias Mamsch - Mon May 25 04:37:52 EDT 2015

jaracic - Thu May 21 16:29:53 EDT 2015

Hi,

I know that without reflexive mechanism in the language I can implement only something "minimalistic". I actually imagined to convert json buffer in  Dxl arrays, Skips and DxlObjects. I imagine to put taht in a top level DxlObject that could contains information about the nature of the content.

Since I don't know how to create its own type , and associated accessors in DXL (any documentation about that issue?), I didn't measure that work.

 

And yes, I have to create a seamless integration demonstrator (as I said I'm not a real programmer) )with a testLink server for a customer.

 

Regards.

Joseph

You can create your own types in DXL. If you look in the forum you will find examples how to do it - the basic idea is to take an underlying type, like Array or Skip/DxlObject (identical) and cast it to a new Type Name.

You can also implement "virtual methods" (i.e. functions that you can assign at runtime), which allows you to replicate simple inheritance on your classes. Using this mechanisms you could build a JSONType class, that will allow you to parse JSONArrays, JSONObject and JSONLiteral instances from that.

If you are interested, I can make a tutorial from this on object oriented DXL programming.

Regards, Mathias

 

 

Re: JSON decoder/encoder in DXL
Wolfgang Uhr - Tue May 26 01:23:09 EDT 2015

Mathias Mamsch - Mon May 25 04:37:52 EDT 2015

You can create your own types in DXL. If you look in the forum you will find examples how to do it - the basic idea is to take an underlying type, like Array or Skip/DxlObject (identical) and cast it to a new Type Name.

You can also implement "virtual methods" (i.e. functions that you can assign at runtime), which allows you to replicate simple inheritance on your classes. Using this mechanisms you could build a JSONType class, that will allow you to parse JSONArrays, JSONObject and JSONLiteral instances from that.

If you are interested, I can make a tutorial from this on object oriented DXL programming.

Regards, Mathias

 

 

Hi Mathias

Independently of this JSON-Problem, such a tutorial may be helpful in any way mainly if there are some improvements compared to your XML-Lib (http://sourceforge.net/projects/dxlstandardlib/).

Otherwise I would say: Your Lib is a tutorial, isn't it?

Best Regards

Wolfgang

Re: JSON decoder/encoder in DXL
jaracic - Tue May 26 03:46:10 EDT 2015

Mathias Mamsch - Mon May 25 04:37:52 EDT 2015

You can create your own types in DXL. If you look in the forum you will find examples how to do it - the basic idea is to take an underlying type, like Array or Skip/DxlObject (identical) and cast it to a new Type Name.

You can also implement "virtual methods" (i.e. functions that you can assign at runtime), which allows you to replicate simple inheritance on your classes. Using this mechanisms you could build a JSONType class, that will allow you to parse JSONArrays, JSONObject and JSONLiteral instances from that.

If you are interested, I can make a tutorial from this on object oriented DXL programming.

Regards, Mathias

 

 

Very instructive thread for me ! I dug a little a I found examples of how to create its own type in DXL. I'll practice that very soon.

Many thanks.

regards.

Joseph.